package com.xiangmu.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {//闁哄啨鍎插﹢鈩冩姜椤掍礁搴婄�规悶鍎遍崣璺ㄧ尵閿燂拷
	
	static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
	
	/**
	 * 闁硅泛顨坅te閺夌儐鍓氶崹姘憋拷娑欘殘椤戜焦绋夐敓锟�
	 * @param date 閻熸洑娴囧ù鍡涘箲閵忋垺鐣遍柡鍐﹀劜濠�锟�
	 * @return 閺夆晜鏌ㄥú鏍ㄦ姜椤掍礁搴婇柛姘捣濞堟垿寮妷锔藉焸閻庢稒顨堥浣圭▔閿燂拷
	 * */
	public static String dateToString(Date date){
		return sdf.format(date);
	}
	
	/**
	 * 闁硅泛锕ら悺褏绮敂鑳洬閺夌儐鍓氶崹娆碼te
	 * @param date 閻熸洑娴囧ù鍡涘箲閵忊�崇亣闁哄啨鍎插﹢锟犳儍閸曨偆鎽熺紒妤嬬細鐟曪拷
	 * @return 閺夆晜鏌ㄥú鏍ㄦ姜椤掍礁搴婇柛姘捣濞堟垿寮妷锔藉焸
	 * */
	public static Date stringToDate(String date){
		try {
			return sdf.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
}
